<?php

namespace Library;

class Database {

	private static $_db;

	public static function getDb() {
		if( self::$_db == null ) {
			$conf = Config::get( 'db' );
			$dsn = $conf['driver'] . ':dbname=' . $conf['dbname'] . ';host=' . $conf['host'];
			try {
				self::$_db = new \PDO( $dsn, $conf['username'], $conf['password'] );
			}
			catch( \PDOException $e ) {
				throw new Exception( $e->getMessage() );
			}
		}
		return self::$_db;
	}

}
